<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.js"></script>
</head>

<body>
    <pre>
        Vue中的数组方法分为两大类
        变更类
            变更类的方法会直接变更原数组，改变页面的视图
        替换类
            替换类的数组方法不会直接改变原数组，而是会形成一个新数组，我们需要把原数组替换为新数组
    </pre>
    <div class="box">
        <input type="text" v-model='msg'><button @click='handle'>添加</button> <button @click='handle1'> 替换</button>
        <ul>
            <li v-for='(item,index) in arr' :key='index'>{{item}}</li>
        </ul>
    </div>
    <script>
        var vm = new Vue({
            el: '.box',
            data: {
                msg: '',
                arr: ['hh', 'pp', 'aa', 'bb', 'cc'],
            },
            methods: {
                handle() {
                    this.arr.push(this.msg)
                },
                handle1() {
                    this.arr = this.arr.slice(0, 3)
                }
            }
        })
    </script>
</body>

</html>